<?php

class Category extends Model {

	function Category()
    {
        parent::Model();
    }
    
	function get_all($pid) 
	{
		$categories = array('0'=>'');
		
		$this->db->select('*');
		$this->db->from('categories');
		$this->db->where('pid', $pid);
		
		$query = $this->db->get();
		
		if ($query->num_rows() > 0)
		{
			// Remove empty index
			unset($categories['0']);
			
			foreach ($query->result() as $row)
			{
				$categories[$row->id] = $row->name;
			}
		}
		
		return $categories;
	}

	function get_subs($parentid)
	{
		$this->db->where("parent_id = {$parentid} AND active = 1");
		$this->db->orderby("category");
		$query = $this->db->get("categories");
		return ($query->result_array());
	} 
	
	function add()
	{
	
	}
	
	function delete()
	{
	
	}
    
    
	
}
